<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>开始使用 layui</title>
    <link href="../assets/modules/layui/css/layui.css" rel="stylesheet">
</head>

<body>
    <form class="layui-form" action="" style="margin-left: 50px;margin-top: 10px;">
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">壁纸名称：</label>
            <div class="layui-input-block">
                <input type="text" name="name" placeholder="请输入壁纸名称" class="layui-input" style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">预览链接：</label>
            <div class="layui-input-block">
                <input type="text" name="preview_url" placeholder="请输入预览链接" class="layui-input" style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">使用类型：</label>
            <div class="layui-input-block">
                <input type="radio" name="vip_type" value="0" title="免费" checked>
                <input type="radio" name="vip_type" value="1" title="付费">
                <input type="radio" name="vip_type" value="2" title="广告">
                <input type="radio" name="vip_type" value="3" title="分享">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">壁纸热度：</label>
            <div class="layui-input-block">
                <input type="text" name="hot" lay-verify="number" placeholder="请输入壁纸热度" class="layui-input"
                    style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">壁纸作者：</label>
            <div class="layui-input-block">
                <input type="text" name="author_uid" lay-verify="number" placeholder="请输入壁纸作者 ID" class="layui-input"
                    style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">壁纸类型：</label>
            <div class="layui-input-block">
                <input type="radio" name="wp_type" value="0" title="All" checked>
                <input type="radio" name="wp_type" value="1" title="Video">
                <input type="radio" name="wp_type" value="2" title="Static">
                <input type="radio" name="wp_type" value="3" title="WP3D">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">静态图片链接：</label>
            <div class="layui-input-block">
                <input type="text" name="wp_url" placeholder="请输入静态壁纸和3D壁纸静态图片链接" class="layui-input"
                    style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">预览视频链接：</label>
            <div class="layui-input-block">
                <input type="text" name="preview_video" placeholder="请输入动态壁纸预览视频链接" class="layui-input"
                    style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">原始视频链接：</label>
            <div class="layui-input-block">
                <input type="text" name="origin_video" placeholder="请输入动态壁纸原始视频链接" class="layui-input"
                    style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">资源编号：</label>
            <div class="layui-input-block">
                <input type="text" lay-verify="number" name="asset_id" placeholder="请输入壁纸资源编号 ID" class="layui-input"
                    style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label" style="width: 100px;">透传参数：</label>
            <div class="layui-input-block">
                <input type="text" name="extra_param" placeholder="请输入透传参数" class="layui-input" style="width: 520px;">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="width: 100px;">壁纸状态：</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" lay-skin="switch" lay-text="ON|OFF" checked>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submitWallpaper">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>


    <script src="../assets/modules/layui/layui.js"></script>
    <script>
        layui.use(['jquery','layer', 'form'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;

            form.on('submit(submitWallpaper)', function (data) {
                layer.load(2);
                $.post('/wallpaper/create', data.field, function (res) {
                    layer.closeAll('loading');
                    if (res.code === 200) {
                        layer.close(index);
                        layer.msg(res.msg, { icon: 1, time: 500 });
                    } else {
                        layer.msg(res.msg, { icon: 2 });
                    }
                });
                return false;
            });

        });
    </script>
</body>

</html>